package com.exl.zkclient.controller;

import com.exl.zkclient.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

  @Autowired
  private OrderService orderService;

  @PostMapping("/stock/deduct")
  public Object reduceStock(int id) throws InterruptedException {
    try {
      //...
      orderService.reduceStock(id);

    } catch (Exception e){
      if (e instanceof RuntimeException){
        throw e;
      }
    }
    return "ok:";
  }

}
